package com.example.goodtrash.mine;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.goodtrash.R;
import com.example.goodtrash.db.RecycleDB;
import com.example.goodtrash.model.Recycle;

public class addRecycle extends AppCompatActivity {
    private EditText edName;
    private EditText edType;
    private EditText edTime;
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_recycle);
        edName=findViewById(R.id.rc_name);
        edType=findViewById(R.id.rc_type);
        edTime=findViewById(R.id.rc_time);
        button=findViewById(R.id.add_recycle);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String name=edName.getText().toString().trim();
                String type=edType.getText().toString().trim();
                String time=edTime.getText().toString().trim();
                RecycleDB db=RecycleDB.getInstance(addRecycle.this);
                Recycle recycle=new Recycle();
                recycle.setName(name);
                recycle.setType(type);
                recycle.setDataTime(time);
                db.saveRecycle(recycle);
                finish();
            }
        });
    }
}